<template>
  <div class="sod-wrapper" :class="{'hidden': startOrder}">
  	<mt-header fixed title="我要出车">
  		<router-link to="/home/map" slot="left">
		    <mt-button icon="back">返回</mt-button>
		</router-link>
  	</mt-header>
  	<div class="start-order">
  		<mt-button type="primary" @click="preGetOrder">我要出车</mt-button>
  	</div>
  </div>
</template>

<script>
import axios from '@/api/axios';
import {mapGetters, mapMutations} from 'vuex';
export default {
	prop: {
		startOrder: {
			type: Boolean,
			default: false
		}
	},
	data: function () {
		return {
			
		}
	},
	methods: {
		...mapGetters(['getSartOrder', 'getId']),
		...mapMutations(['setStartOrder']),
		preGetOrder: function () {
			var setting = {
				method: 'POST',
				url: '/getsetTruckSingleState'
			};
			var data = {
				phone: this.getId(),
                ckgrp: 'set_state',
			}
			axios((res) => {
				if(res.code === 0) {
					var state = res.data === 1 ? true : false;
					this.$toast('可以出车了');
					this.setStartOrder(state);
				}else {
					this.$toast('网络错误');
				}
			}, {setting, data})
		}
	},
	computed: {
		startOrder: {
			get: function () {
				return this.getSartOrder();
			}
		}
	}
}
</script>

<style>
 .sod-wrapper {
	position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    width: 100%;
    z-index: 1000;
    background-color: rgb(255,255,255);
}
.start-order {
	margin-top: 50%;
    text-align: center;
}
.hidden {
	display: none;
}
</style>
